<%-- 
    Document   : add.jsp
    Created on : 22.11.2014, 12:53:26
    Author     : David Katuscak, 359273
--%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>  

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title><fmt:message key="edit" /></title>
    </head>
    <body>
        <div class="container">
            <c:if test="${null != revision}">
                <h2><fmt:message key="revision.addNew" /></h2>

                <c:url var="saveUrl" value="/revision/add" />
                <form:form method="POST" role="form" action="${saveUrl}" class="form-horizontal" modelAttribute="revision">

                    <spring:bind path="machine">
                        <div class="form-group ${status.error ? 'has-error' : ''}">
                            <form:label path="machine" class="control-label col-sm-2"><fmt:message key="machine" />:</form:label>
                                <div class="col-sm-10">
                                <form:select path="machine" class="form-control">
                                    <form:options items="${machinesMap}" />
                                </form:select>
                            </div>
                            <form:errors path="machine" class="control-label col-sm-4"  />
                        </div>
                    </spring:bind>

                    <spring:bind path="dateOfRevision">
                        <div class="form-group ${status.error ? 'has-error' : ''}">
                            <form:label path="dateOfRevision" class="control-label col-sm-2"><fmt:message key="revision.dateofrevision" />:</form:label>
                                <div class="col-sm-10">
                                <form:input path="dateOfRevision" id="datepicker" class="form-control" />
                            </div>
                            <form:errors path="dateOfRevision" class="control-label col-sm-4"  />
                        </div>
                    </spring:bind>

                    <spring:bind path="description">
                        <div class="form-group ${status.error ? 'has-error' : ''}">
                            <form:label path="description" class="control-label col-sm-2"><fmt:message key="revision.description" />:</form:label>
                                <div class="col-sm-10">
                                <form:textarea rows="5" cols="30" maxlength="255" path="description" class="form-control" />
                            </div>
                            <form:errors path="description" class="control-label col-sm-4"  />
                        </div>
                    </spring:bind>

                    <div class="form-group">        
                        <div class="col-sm-offset-2 col-sm-9">
                            <button type="submit" class="btn btn-default"><fmt:message key="save" /></button>
                            <a href="<c:url value="/machine/detail/${revision.machine.id}" />" onclick="return confirm('<fmt:message key="cancel.confirm" />')"><fmt:message key="revision.cancelchanges" /></a>
                        </div>
                    </div>
                </form:form>
            </c:if>
        </div>
    </body>
</html>

